﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>NFA</title>


        <script type="text/javascript" src="http://localhost:8080/nfa/js/jquery-2.1.1.min.js"></script>
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/style.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/dropzone.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/bootstrap-theme.css"  />
        <script type="text/javascript" src="http://localhost:8080/nfa/js/bootstrap.js"></script>

        <script type="text/javascript" src="http://localhost:8080/nfa/js/jquery.validate.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/messages_vi.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/js.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/popbox.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/dropzone.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/autoload.js"></script>
        <script type='text/javascript' charset='utf-8'>
            // document.getElementById("ob").scrollTop = 9999999;
            $(document).ready(function() {
                $('.popbox').popbox();
                $("#edit-stt").click(function() {
                    $("#stt").hide();
                    $("#form-stt").show();
                    $("#edit-stt").hide();
                });


            });
        </script>


    </head>
    <?php
    $image = $this->connect->getinfo($this->session->userdata("email"));
    foreach ($image as $i) {
        $avarta = $i->avarta;
        $ten = $i->name;
        $truong = $i->education;
        $city = $i->city;
        $stt = $i->status;
        $cao = $i->height;
        $nang = $i->weight;
        $toi = $i->about_me;
        $ban = $i->about_you;
        $tim = $i->find_age;
        $mucdich = $i->target;
        $gt = $i->gender;
        $dotuoi = $i>find_age;
    }
    ?>
    <body onload="updateAlerts();
                updateconversations();
                updateRequest();
                getRequest();
                loadnotice();
                updatenotice();">

        <!-- header -->
        <header>
            <nav class="navbar navbar-fixed-top navbar-default" role="navigation" style="height:50px !important ;">
                <div class="center">	
                    <div class="container-fluid">
                        <!-- Brand and toggle get grouped for better mobile display -->
                        <div class="navbar-header" style="width: 8%;">

                            <a class="navbar-brand" href="#" style=" font-size:30px; color:#F06; ;">NFA</a>
                        </div>

                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div>
                            <div >
                                <ul class="nav navbar-nav" style=" width: 20%;">

                                    <li class="notice">


                                        <div class='popbox'>

                                            <div  style="text-align: center;" class='open'  >
                                                <span  class="glyphicon glyphicon-user"><span id="request" class="badge"></span></span>
                                            </div>


                                            <div class='collapse-one'>
                                                <div class='box' >
                                                    <div class='arrow'></div>
                                                    <div class='arrow-border'></div>

                                                    <div class="popbox-content">
                                                        <div class="popbox-header">Yêu cầu kết bạn</div>
                                                        <div class="popbox-data">
                                                            <ul id="friend-request">

                                                            </ul>
                                                        </div>
                                                        <div class="popbox-footer">
                                                            <a href="#">Xem tất cả</a>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                        </div>



                                    </li>
                                    <li class="notice">
                                        <a class='open' data-toggle="modal" data-target="#inbox">
                                            <span class="glyphicon glyphicon-comment"><span id="count-message" class="badge"></span></span>
                                        </a>
                                    </li>
                                    <li class="notice">


                                        <div class='popbox' >
                                            <div  style="text-align: center;" class='open'  >

                                                <span class="glyphicon glyphicon-exclamation-sign"><span id="count-notice" class="badge"></span></span>

                                            </div>

                                            <div class='collapse-one'>
                                                <div class='box' >
                                                    <div class='arrow'></div>
                                                    <div class='arrow-border'></div>

                                                    <div class="popbox-content">
                                                        <div class="popbox-header">Bảng tin</div>
                                                        <div class="popbox-data">
                                                            <ul id="notice">

                                                            </ul>
                                                        </div>
                                                        <div class="popbox-footer">
                                                            <a href="#">Xem tất cả</a>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                        </div>

                                    </li>

                                </ul>
                            </div>
                            <div style="height: 0;" >
                                <form id="sb"  style="padding-top: 0.7%;" method="get" action="http://localhost:8080/nfa/index.php/search/searchquick">
                                    <div class="input-group" style="width:40%;">
                                        <input autocomplete="off" type="text"  id="keywords" name="kw"  class="form-control" placeholder="Tìm kiếm tên hoặc email ...." />
                                        <span class="input-group-btn">
                                            <button id="btn-search" class="btn btn-success" type="submit">Tìm kiếm</button>
                                        </span>
                                    </div>
                                    <div  id="results" style="width:40%; margin-left: 28%;">

                                    </div>


                                </form><!-- /.col-lg-6 -->
                            </div>
                            <div style="float: right;">
                                <ul class="nav navbar-nav" >
                                    <?php if ($this->session->userdata('email')) { ?>
                                        <li class="notice"><a href="http://localhost:8080/nfa/index.php/home/mypage"><img src="http://localhost:8080/nfa/images/avarta/<?php echo $avarta; ?>" class="notice-area"  /> <?php echo $ten; ?></a></li>
                                    <?php } else { ?>
                                        <li class="notice"><a href="http://localhost:8080/nfa/index.php/home/mypage"><img src="http://localhost:8080/nfa/images/avarta/user_male4.png" class="notice-area"  /> <?php echo $ten; ?></a></li>

                                    <?php } ?> 
                                    <li class="notice">
                                        <a href="http://localhost:8080/nfa/index.php/home">Home</a>
                                    </li>
                                    <li class="dropdown notice">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> <b class="caret"></b></a>
                                        <ul class="dropdown-menu">
                                            <li><a href="">Thiết lập</a></li>
                                            <li><a href="http://localhost:8080/nfa/index.php/login/logout">Thoát</a></li>

                                        </ul>
                                    </li>

                                </ul>
                            </div>
                        </div><!-- /.navbar-collapse -->
                    </div><!-- /.container-fluid -->
                </div>
            </nav>
        </header>

        <!-- message -->
        <div class="modal fade" id="inbox" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel"> Tin nhắn</h4>
                    </div>

                    <div class="modal-body">
                        <div class="row">
                            <div class="col-xs-6 col-md-4" style="overflow : auto;" >
                                <ul id="coversations" class="list-group">

                                </ul>
                                <p id="typing"></p>
                            </div>
                            <div class="col-xs-12 col-md-8">
                                <div class="panel panel-default">
                                    <div class="panel-body" id="ob" style="height: 380px; overflow : auto;" >
                                        <ul id="tinnhan">

                                        </ul>
                                    </div>
                                    <div class="panel-footer" >
                                        <form id="chat-box" method="post">

                                            <input type="hidden" name="id" value="" id="id-chat"/>
                                            <textarea name="chat" id="chatchit" class="form-control"   rows="3"></textarea> 

                                        </form>

                                    </div>
                                </div>
                                <p style="float: right; font-weight: bold;"><span class="glyphicon glyphicon-ok-circle"></span> Nhấn enter để gửi</p>
                            </div>
                        </div>
                    </div>


                </div>
            </div>
        </div>
        <div class="center">
            <div class="row" style="padding-top:6%;">
                <div class="col-xs-3 col-md-2">
                    <div class="list-group" style="position: fixed;">
                        <a href="#" class="list-group-item active"><span class="glyphicon glyphicon-home"></span> Trang cá nhân</a>
                        <a href="#myalbum" class="list-group-item "><span class="glyphicon glyphicon-picture"></span><span class="badge">14</span> Album Ảnh</a>
                        <a href="#" class="list-group-item "><span class="glyphicon glyphicon-heart-empty"></span><span class="badge">14</span>  Hẹn hò</a>
                        <a href="#" class="list-group-item "><span class="glyphicon glyphicon-user"></span><span class="badge">14</span>  Bạn bè</a>
                        <a href="#" class="list-group-item "><span class="glyphicon glyphicon-star"></span><span class="badge">14</span>  Yêu thích</a>
                        <a href="#" class="list-group-item "><span class="badge">14</span>Người theo dõi</a>

                    </div>
                </div>

                <div class="col-xs-12 col-md-6">

                    <div class="panel panel-info" >

                        <div class="panel-body">
                            <div>
                                <h3 style="color: #F0A;"> <?php echo $ten; ?></h3>

                            </div>
                            <div>
                                <p> <?php echo $city; ?>, 23 tuổi, Thần Nông</p>
                            </div>
                            <div>
                                <div class="col-sm-3 ">
                                    <img class="img-thumbnail" style="width: 120px; height:120px;" src="http://localhost:8080/nfa/images/avarta/<?php echo $avarta; ?>" />
                                </div>
                                <div class=" radio-inline">
                                    <div class="well " style="height: 100px; width: 350px;">
                                        <div class="text-right" style="margin-top:-2%; margin-bottom: 10px;">
                                            <span id="edit-stt" class="glyphicon glyphicon-pencil"></span>
                                        </div>
                                        <div id="stt">
                                            <p><?php echo $stt; ?></p>
                                        </div>
                                        <div  id="form-stt" style="display: none ;">
                                            <form class="form-group" action="<?php echo base_url('user/updatestt'); ?>" method="post">
                                                <input class="form-control" autocomplete="off" type="text" name="stt" value=""  style=" width: 80%;height: 50px; float:left; margin-right:5%;"/>
                                                <button type="submit" class="btn btn-primary" style="float:left; " ><span class="glyphicon glyphicon-ok"></span></button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <br />
                            <div class="btn-group ">
                                <button type="button" class="btn btn-default" data-toggle="modal" data-target="#updateavarta"><span class="glyphicon glyphicon-user"></span> Sửa avarta  </button>
                                <button type="button" class="btn btn-info"><span class="glyphicon glyphicon-info-sign"></span> Cập nhật thông tin</button>
                                <button type="button" id="gift" class="btn btn-warning"><span class="glyphicon glyphicon-cog"></span> Thiết lập</button>                   
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-xs-6 col-md-4">
                    <div class="panel panel-info">
                        <h4 style="text-align: center;"> <img src="http://localhost:8080/nfa/icon/1399832230_red-21.png" style="margin-right:5%;"/>Thành viên phù hợp với bạn </h4>
                        <div class="panel-body">

                        </div>

                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3 col-md-2">
                </div>
                <div class="col-xs-12 col-md-6">
                    <div class="panel panel-success">
                        <div class="panel-heading">
                            <b>HẸN HÒ</b>
                            <span class="glyphicon glyphicon-pencil " style="float:right; " id="edit-henho"></span>
                        </div>
                        <div class="panel-body">
                            <div class="info-private">
                                <span class="glyphicon glyphicon-heart"></span> &nbsp   Quan tâm đến : <?php
                                if ($gt == 'Nữ') {
                                    echo 'Nam';
                                } else {
                                    echo 'Nữ';
                                }
                                ?>

                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-search"></span> &nbsp      Độ tuổi tìm kiếm : <?php echo $tim; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-screenshot"></span>&nbsp Mục đích hẹn hò: <?php echo $mucdich; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-thumbs-up"></span>&nbsp  Mẫu người ưa thích  : <?php echo $ban; ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6 col-md-4">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <b>VỀ BẠN</b>
                            <span class="glyphicon glyphicon-pencil " style="float:right; " id="edit-about"></span>
                        </div>
                        <div class="panel-body">
                            <div class="info-private">
                                <span class="glyphicon glyphicon-bookmark"></span>&nbsp  Về tôi : <?php echo $toi; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-book"></span> &nbsp Học tại : <?php echo $truong; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-home"></span>&nbsp Sống tại : <?php echo $city; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-sort-by-attributes"></span> &nbsp Chiều Cao : <?php echo $cao; ?>
                            </div>
                            <div class="info-private">
                                <span class="glyphicon glyphicon-align-justify"></span>&nbsp  Cân nặng : <?php echo $nang; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row" id="myalbum">
                <div class="col-xs-3 col-md-2">
                </div>
                <div class="col-xs-18 col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <b>ALBUM ẢNH</b>

                        </div>
                        <div class="panel-body">
                            <a class='open' data-toggle="modal" data-target="#createAlbum" >
                                <div class="album-first">
                                    <br/> <br/> <br/> 
                                    Tạo album
                                </div>
                            </a>

                            <?php
                            $a = $this->connect->getalbum($this->session->userdata("id"));
                            foreach ($a as $y) {
                                $albumId = $y->album_id;
                                $albumTitle = $y->title;
                                $userId = $y->user_id;
                                $date_create = $y->time_create;
                                $c = $this->connect->getlastphoto($albumId);


                                $b = $this->connect->getphoto($albumId);
                                ?>
                                <a class='open' onclick="cleanphoto();
                    loadphoto(<?php echo $albumId; ?>);" data-toggle="modal" data-target="#album<?php echo $albumId; ?>">
                                    <div class="album">

                                        <div style="padding-left:  0;">
                                            <?php
                                            if (count($b)) {
                                                foreach ($c as $o) {
                                                    $id = $o->photo_id;
                                                }
                                                $d = $this->connect->getphoto2($id);
                                                foreach ($d as $p) {
                                                    $lastphoto = $p->photo_url;
                                                }
                                                ?>
                                                <img class="img-album " src="http://localhost:8080/nfa/images/photo/<?php echo $lastphoto; ?>"/>
                                            <?php } else { ?>
                                                <img class="img-album " src="http://localhost:8080/nfa/images/images.jpg"/>
                                            <?php } ?>

                                        </div >
                                        <div style="padding-left: 2%; ;">
                                            <a style="color: #269abc;"><?php echo $albumTitle; ?></a> <br/>
                                            <?php echo count($b) ?> ảnh
                                        </div>

                                    </div>
                                </a>

                                <!-- album detail -->

                                <div class="modal fade" id="album<?php echo $albumId; ?>" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                <h4 class="modal-title" id="myModalLabel"> Album : <?php echo $albumTitle; ?></h4>
                                            </div>

                                            <div class="modal-body" style="height: 470px;">

                                                <div class="" style="overflow : auto; float: left; width: 32%; margin-right: 1%;  " >
                                                    <div class="panel panel-default" style="height: 450px;">
                                                        <div class="panel-body"  style="" >
                                                            <div id="loadphoto"> </div>

                                                        </div>
                                                    </div>

                                                </div>
                                                <div class="" style="float: left; width: 67%;">
                                                    <div class="panel panel-default" style="height: 450px;  ">

                                                        <ul class="photo" style="padding-top: 2%; ">

                                                        </ul>

                                                    </div>
                                                </div>

                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deletealbum<?php echo $albumId; ?>" style="float: left;">Xóa album</button>
                                                <button type="button" class="btn btn-primary" style="float: left;" data-toggle="modal" data-target="#addphoto<?php echo $albumId ?>">Tải thêm ảnh</button>
                                                <button type="button" class="btn btn-default" data-dismiss="modal">Trở về</button>

                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <!-- add photo -->
                                <div class="modal fade" id="addphoto<?php echo $albumId ?>" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                <h4 class="modal-title" id="myModalLabel"> Tải ảnh mới vào album</h4>
                                            </div>

                                            <div class="modal-body">

                                                <div class="form-group" style="padding-bottom: 3%;">
                                                    <label for="title_album" class="col-sm-2 control-label">Album : <?php echo $albumTitle; ?></label>


                                                </div>
                                                <div class="form-group">
                                                    <form action="http://localhost:8080/nfa/index.php/photo/addphoto" method="post" id="drop-zone"  class="dropzone" enctype="multipart/form-data">
                                                        <input type="hidden" name="albumid" value="<?php echo $albumId ?>"/>
                                                    </form>
                                                </div>



                                            </div>
                                            <div class="modal-footer">


                                                <button id="add_photo" class="btn btn-success" style="float:left;"onclick="loadphoto(<?php echo $albumId; ?>);
                    cleanphoto();" data-dismiss="modal" >Hoàn Tất </button>
                                                <button id="cancel_addphoto" data-dismiss="modal" class="btn btn-warning">Trở về </button>


                                            </div>


                                        </div>
                                    </div>
                                </div>


                                <!-- delete album -->
                                <div class="modal fade" id="deletealbum<?php echo $albumId; ?>" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
                                    <div class="modal-dialog modal-sm">
                                        <div class="modal-content">
                                            <div class="modal-body">
                                                <b> Bạn có chắc là muốn xóa album  này ?</b>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-success" onclick="deletealbum(<?php echo $albumId; ?>);" data-dismiss="modal" >Chắc chắn rồi</button>
                                                <button type="button" class="btn btn-primary" data-dismiss="modal"> Nhầm thôi</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <?php
                                foreach ($b as $k) {
                                    $photoID = $k->photo_id;
                                    ?>
                                    <!-- delete photo --> 
                                    <div class="modal fade" id="photo<?php echo $photoID; ?>" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
                                        <div class="modal-dialog modal-sm">
                                            <div class="modal-content">
                                                <div class="modal-body">
                                                    <b> Bạn có chắc là muốn xóa hình này ?</b>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-success" onclick="deletephoto(<?php echo $photoID; ?>);
                        loadphoto(<?php echo $albumId; ?>);
                        cleanphoto();" data-dismiss="modal">Chắc chắn rồi</button>
                                                    <button type="button" class="btn btn-primary" data-dismiss="modal"> Nhầm thôi</button>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                    <?php
                                }
                            }
                            ?>
                        </div>
                    </div>
                    <!-- create new album -->
                    <div class="modal fade" id="createAlbum" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h4 class="modal-title" id="myModalLabel"> Tạo album mới</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-group" style="padding-bottom: 3%;">
                                        <label for="title_album" class="col-sm-2 control-label">Tiêu đề Album :</label>
                                        <div class="col-sm-5">
                                            <input type="text" id="title_album" class="form-control"  placeholder="Tiêu đề" />
                                        </div>
                                        <div class="col-sm-5">
                                            <div  id="alert_title" class="alert alert-warning" style="display: none;"></div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <form action="http://localhost:8080/nfa/index.php/photo/upload" id="drop-zone"  class="dropzone" enctype="multipart/form-data">

                                        </form>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button id="create_album" class="btn btn-success" style="float:left; " >Hoàn Tất </button>
                                    <button id="cancel_album" class="btn btn-warning">Trở về </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-xs-3 col-md-2">
                </div>
                <div class="col-xs-18 col-md-10">
                    <div class="panel panel-success">
                        <div class="panel-heading">
                            BẠN BÈ
                        </div>
                        <div class="panel-body">
                            <?php
                            $i = $this->connect->getfriend($this->session->userdata("id"));
                            foreach ($i as $a) {
                                $id1 = $a->user_id1;
                                $id2 = $a->user_id2;
                                if ($id1 == $this->session->userdata('id')) {
                                    $h = $this->connect->getID($id2);
                                    $o = $id2;
                                    foreach ($h as $m) {
                                        $anh = $m->avarta;
                                        $ten = $m->name;
                                        $city = $m->city;
                                    }
                                } else {

                                    $j = $this->connect->getID($id1);
                                    $o = $id1;
                                    foreach ($j as $m) {
                                        $anh = $m->avarta;
                                        $ten = $m->name;
                                        $city = $m->city;
                                    }
                                }
                                ?>
                                <div style="float: left; padding-top: 2%; padding-top: 1%;width:50%; padding-bottom: 1%;"  >
                                    <div style="float: left;">
                                        <a id="anh"   href="<?php echo base_url("getid?id=" . $o); ?>"><img style="height: 170px; width: 130px;" class="img-thumbnail" src="http://localhost:8080/nfa/images/avarta/<?php echo $anh; ?>"></a>
                                    </div>
                                    <div style="float: left; padding-left: 2%;">
                                        <a href="" href="<?php echo base_url("getid?id=" . $o); ?>"><p><?php echo $ten; ?>  </p></a>
                                        <p><?php echo $city; ?></p>



                                    </div>
                                </div>
                            <?php } ?> 
                        </div>
                    </div>
                </div>
            </div>



        </div>
        
        <!-- update avarta-->
        <div class="modal fade" id="updateavarta" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Đổi ảnh đại diện</h4>
                    </div>
                    <form   method="post" action="<?php echo base_url() ."user/uploadavarta" ?>" enctype="multipart/form-data">

                        <div class="modal-body" >

                            <div>
                                <img id="img_prev" class="anhnho6" src="http://localhost:8080/nfa/images/avarta/<?php echo $avarta; ?>"/>
                            </div>

                            <div>
                                <br/>
                                <input type="file" name="avarta"  onchange="readURL(this);" />

                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-success" >Cập nhật</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Trở về</button>

                        </div>
                    </form>
                </div>
            </div>
        </div>




    </body>

</html>
<script type="text/javascript">
            function readURL(input) {
                if (input.files && input.files[0]) {
                    var reader = new FileReader();

                    reader.onload = function(e) {
                        $('#img_prev').attr('src', e.target.result)
                                .width(120)
                                .height(120);
                    };
                    reader.readAsDataURL(input.files[0]);
                }
            }
            function cleanphoto() {
                $(".photo").empty();
            }
            function loadnotice() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/dating/loadnotification",
                    success: function(data) {
                        $("#notice").empty();
                        $("#notice").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('loadnotice()', 500); // Every 15 seconds.
            }
            function updatenotice() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/dating/checknotice",
                    success: function(data) {
                        $("#count-notice").empty();
                        $("#count-notice").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updatenotice()', 1000); // Every 15 seconds.

            }


            function zoomphoto(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/getphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $(".photo").html(data);


                    }
                });



            }
            function loadphoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/loadphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#loadphoto").html(data);

                    }
                });

            }
            function deletephoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletephoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {

                    }
                });

            }
            function deletealbum(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletealbum",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        window.location = "http://localhost:8080/nfa/index.php/home/mypage";
                    }
                });

            }

            function  getbutton() {

                var id = $("#user-id").val();
                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/getbutton', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {
                        $("#btn-friend").html(data);
                    },
                    error: function(e) {
                        console.log(e);
                    }

                });
                setTimeout('getbutton()', 500);

            }

            function  agree(id) {


                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/agree', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {

                    },
                    error: function(e) {
                        console.log(e);
                    }

                });

            }
            var myvar;

            function updateRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/checkrequest",
                    success: function(data) {
                        $("#request").empty();
                        $("#request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateRequest()', 1000); // Every 15 seconds.
            }
            function getRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/getrequest",
                    success: function(data) {
                        $("#friend-request").empty();
                        $("#friend-request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('getRequest()', 500); // Every 15 seconds.
            }

            function updateAlerts() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/checkmessage",
                    success: function(data) {
                        $("#count-message").empty();
                        $("#count-message").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateAlerts()', 1000); // Every 15 seconds.

            }
            function updateconversations() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getconversations",
                    success: function(data) {
                        $("#coversations").empty();
                        $("#coversations").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateconversations()', 500); // Every 15 seconds.

            }

            function updatemessage(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getmessage",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#tinnhan").html(data);
                        $("#id-chat").val(id);

                    }
                });
                myvar = setTimeout(function() {
                    updatemessage(id);
                }, 500);
                ;


            }
            function myStopFunction() {
                clearTimeout(myvar);
            }
            function updatestt(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/updatestt",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {


                        //
                        // Do something similar for unreadMessages, if required...
                    }
                });

            }



</script>
